<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="../bootstrap/bootstrap.min.css">
    <script src="../jquery/jquery-1.8.3.js"></script>
</head>
<style type="text/css">
    .div_ads {
        width: 75%;
        margin: 50px auto 0 0;
    }

    table {
        margin: 0 auto;
        width:100%;
        border-collapse:separate;
        border-spacing:0px 10px;
    }
    table tr td {
        text-align: center;
        width:150px;
        height:44px;
    }
</style>
<script>
    $(function () {
        //获取会话对象中的键值对
        var stuNum = sessionStorage.getItem('stuName');
        var stuName =  sessionStorage.getItem('stuName');


        //使用ajax请求servlet---数据库
        $.ajax({
            url:"/StuTea/ServletupTea",
            dataType:"json",
            contentType: "Application/json",
            data:{
               /* "stuNum":stuNum,
                "stuName":stuName*/
            },
            success:function (data) {
                //解析返回数据,填充到HTML中,不需要使用EL或JSTL
                if(data != null && data !=""){
                  // alert(data);
                    $("#num").val(data.teaNum);
                    $("#name").val(data.teaName);
                    if(data.teaSex == '男'){
                        $("#s1").attr("selected","selected");
                    }else {
                        $("#s2").attr("selected","selected");
                    }
                    $("#age").val(data.teaAge);
                    $("#course").val(data.teaCourse);
                    $("#major").val(data.major);
                    $("#department").val(data.department);
                }
            }
        })

        //
        // var span = $("span").val();
        // if(span!=null){
        //     span.val("修改成了")
        // }




    })
</script>

<!-- action我只写ServletEditTeacherInfo。浏览器端报404路径/StuTea/teacher/ServletEditTeacherInfo,所以浏览器默认是从webapp里开始找起的。java文件下的写绝对路径。-->
<body>
<form action="/StuTea/ServletEditTeacherInfo" method="post">
    <div class="div_ads">
        <span></span>
        <table>
            <tr>
                <td>学&nbsp;&nbsp;&nbsp;号：</td>
                <td><input type="text" id="num" name="teaNum" class="form-control" value="" readonly="readonly" /></td>
            </tr>
            <tr>
                <td>姓&nbsp;&nbsp;&nbsp;名：</td>
                <td><input type="text" id="name" name="teaName" class="form-control" value="" /></td>
            </tr>
            <tr>
                <td>性&nbsp;&nbsp;&nbsp;别：</td>
                <td>
                    <select name="teaSex" class="form-control">
                        <option value="男"  id="s1" >男</option>
                        <option value="女"  id="s2" >女</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td>年&nbsp;&nbsp;&nbsp;龄：</td>
                <td><input type="text"  id="age"  name="teaAge" class="form-control" value="" /></td>
            </tr>
            <tr>
                <td>课&nbsp;&nbsp;&nbsp;程：</td>
                <td><input type="text"  id="course" name="teacourse" class="form-control" value="" /></td>
            </tr>
            <tr>
                <td>专&nbsp;&nbsp;&nbsp;业：</td>
                <td><input type="text"  id="major"  name="major" class="form-control" value="" /></td>
            </tr>
            <tr>
                <td>院&nbsp;&nbsp;&nbsp;系：</td>
                <td><input type="text"  id="department"  name="department" class="form-control" value="" /></td>
            </tr>
            <tr>
                <td><input type="submit" value="修改" class="btn btn-primary" /></td>
                <td><input type="reset" value="清空" class="btn btn-danger" /></td>
<!--                <span id="span" value="12">afafaf</span>-->
            </tr>
        </table>
    </div>
</form>
</body>
</html>